<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <title>电影商城</title>
    <link href="./themes/ecmoban_dangdang/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div id="app">
        <div class="top_nav">
            <div class="block">
                <ul class="top_bav_l">
                </ul>
                <div class="header_r">
                    <font id="ECS_MEMBERZONE" v-if="islogin"> 欢迎光临电影商城！ <s></s>&nbsp; <span> <a style="color: #FF6766;"
                        href="login.html">[观众登录]</a> <a style="color: #FF6766;" href="register.html">[观众注册]</a>
						<a style="color: #FF6766;" href="slogin.html">[影院登录]</a>
						<a style="color: #FF6766;" href="sregister.html">[影院注册]</a>
                </span>
                    </font>
                    <font id="ECS_MEMBERZONE" v-if="!islogin"> 欢迎电影推荐系统 <b>{{ realname }}</b> <span><a
                        style="color: #FF6766;" href="cart.html">[购物车]</a><a style="color: #FF6766;" href="usercenter.html">[观众中心]</a> <a
                        style="color: #FF6766;" href="exit.html">[退出系统] </a> </span>
                    </font>
                </div>
            </div>
        </div>
        <div class="clearfix">
            <div class="block header">
                <div class="top">
                    <a href="index.html" class="logo"><img src="themes/ecmoban_dangdang/images/logo.gif" /></a>
                    <div class="head_r">
                        <div class="top_shopCart clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
        <div style="clear: both"></div>
        <div class="menu_box clearfix">
            <div class="block">
                <div class="menu">
                    <a href="index.html" class="cur" rel="nofollow">网站首页</a>
                    <a href="article.html" class="cur" rel="nofollow">电影商城公告</a>
                    <a href="recommend.html" class="cur" rel="nofollow">智能推荐电影</a>
                    <a href="all.html" class="cur" rel="nofollow">全部电影</a>
                </div>
            </div>
        </div>
        <div class="blank"></div>
        <div class="block table">
            <div class="flowBox">
                <h6>
                    <span>购物车</span>
                </h6>
                <table width="99%" align="center" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
                    <tr>
                        <th bgcolor="#ffffff">电影名称</th>
                        <th bgcolor="#ffffff">价格</th>
                        <th bgcolor="#ffffff">数量</th>
                        <th bgcolor="#ffffff">日期</th>
                        <th bgcolor="#ffffff">操作</th>
                    </tr>
                    <tr v-for="item in cartList" :key="item.cartid">
                        <td bgcolor="#ffffff" align="center" style="width: 300px;">
                            <a :href="'detail.html?id='+item.goodsid+''" target="_blank"> <img style="width: 80px; height: 80px;" :src="'http://127.0.0.1:8080/vue_gxhfztjxt/upfiles/'+item.goods.image" border="0" title="" />
                            </a> <br /> <a :href="'detail.html?id='+item.goodsid+''" target="_blank" class="f6">{{item.goodsname}}</a></td>
                        <td align="center" bgcolor="#ffffff">￥{{item.price}}元</td>
                        <td align="center" bgcolor="#ffffff">{{item.num}}</td>
                        <td align="center" bgcolor="#ffffff">{{item.addtime}}</td>
                        <td align="center" bgcolor="#ffffff"><a href="javascript:" class="f6" @click="deleteCart(item.cartid)">移除</a></td>
                    </tr>
                </table>


                <table width="99% " align="center " border="0 " cellpadding="5 " cellspacing="0 " bgcolor="#dddddd ">
                    <tr>
                        <td bgcolor="#ffffff ">
                            <a href="index.html"><img src="themes/ecmoban_dangdang/images/continue.gif " alt="continue " /> </a>
                        </td>
                        <td bgcolor="#ffffff " align="right ">
                            <a href="javascript:" @click="checkout()"><img src="themes/ecmoban_dangdang/images/checkout.gif " alt="checkout " /> </a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="blank "></div>

            <div class="blank5 "></div>
        </div>
        <div id="footer">
            <div class="footer">
                <div class="footer_nav_box">
                    <div class="footer_copyright">
                        <span> &copy;  电影商城 版权所有，并保留所有权利。<br /> <br />服务时间：09:00-23:00<br /> <br /> <a href="../admin/index.html"
                            target="_blank">管理员入口</a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<!--此页面业务相关的脚本-->
<script type="text/javascript" src="../admin/assets/layui/layui.js"></script>
<script type="text/javascript" src="../admin/assets/js/axios.min.js"></script>
<script type="text/javascript" src="../admin/assets/js/vue.js"></script>
<script type="text/javascript" src="../admin/assets/js/jquery.min.js"></script>
<script type="text/javascript ">
    const vue = new Vue({ // 实例化Vue对象
        el: '#app', // 绑定作用域
        data: { //定义数据 用于vue的双向绑定
            islogin: '',
            userid: '',
            username: '', // 观众名
            realname: '', // 定义姓名数据
            cartList: {},
            num: 0,
        },
        methods: {
            loadPage: function() {
                let _this = this;
                _this.userid = sessionStorage.getItem('userid');
                _this.islogin = sessionStorage.getItem('userid') == null;
                _this.realname = sessionStorage.getItem('realname');
                axios.get('http://127.0.0.1:8080/vue_gxhfztjxt/index/cart.action?userid=' + _this.userid).then(result => {
                    _this.cartList = result.data.cartList;
                    _this.num = result.data.num;
                });
            },
            deleteCart: function(cartid) { // 根据主键删除管理员信息
                let _this = this;
                if (window.confirm('确定要删除这条记录吗？')) {
                    axios.get('http://127.0.0.1:8080/vue_gxhfztjxt/index/deletecart.action?id=' + cartid).then(result => {
                        if (result.data.code > 0) {
                            _this.loadPage();
                        } else {
                            alert('系统错误，请稍后再试');
                        }
                    });
                }
            },
            checkout: function() {
                if (this.num != 0) {
                    window.location.href = "checkout.html";
                } else {
                    alert('请选购商品');
                }
            },
        },
        created() { // 生命周期相关的函数
            this.loadPage();
        },
    })
</script>
<!--作者联系 QQ 1420527913   毕设成品下载网址  codebag.cn-->
</html>